﻿using System;

namespace UnitBox.Fixtures {
	/// <summary>
	/// A test stub used to test interception of static calls.
	/// </summary>
	public class StaticThing {

		#region class fields

		private static string _someThing;

		private static bool _SomeThingGetterWasCalled;
		private static bool _SomeThingSetterWasCalled;
		private static bool _DoSomethingWasCalled;
		private static bool _DoSomethingThatReturnsWasCalled;

		#endregion


		#region constructors

		public StaticThing() {
			_DoSomethingWasCalled = false;
			_DoSomethingThatReturnsWasCalled = false;
		}

		#endregion


		#region properties

		public static string SomeThing {
			get {
				_SomeThingGetterWasCalled = true;
				return _someThing;
			}
			set {
				_SomeThingSetterWasCalled = true;
				_someThing = value;
			}
		}


		public static bool SomeThingGetterWasCalled {
			get { return _SomeThingGetterWasCalled; }
		}


		public static bool SomeThingSetterWasCalled {
			get { return _SomeThingSetterWasCalled; }
		}


		public static bool DoSomethingWasCalled {
			get { return _DoSomethingWasCalled; }
		}


		public static bool DoSomethingThatReturnsWasCalled {
			get { return _DoSomethingThatReturnsWasCalled; }
		}

		#endregion


		#region public methods

		public static void DoSomething() {
			_DoSomethingWasCalled = true;
		}


		public static string DoSomethingThatReturns() {
			_DoSomethingThatReturnsWasCalled = true;

			return "I was called!";
		}


		public static void ResetState() {
			_SomeThingGetterWasCalled = false;
			_SomeThingSetterWasCalled = false;
			_DoSomethingWasCalled = false;
			_DoSomethingThatReturnsWasCalled = false;
		}

		#endregion

	}
}
